package com.neusoft.elm.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtil {
	
	private static String DRIVER = "com.mysql.jdbc.Driver";
	private static String URL="jdbc:mysql://127.0.0.1:3306/elm_admin";
	private static String USERNAME="root";
	private static String PASSWORD="1234";
	
	
	
	//获取Connection
	public static Connection getConnection(){
		Connection con = null;
		
		try {
			//��������
			Class.forName(DRIVER);
			//�������ݿ�
			con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
			
			
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return con;
		
	}
	//�ͷ���Դ
	public static void CloseAll(ResultSet rs,PreparedStatement pst,Connection con){
		
			try {
				if(rs!=null){
					rs.close();
				}
				if(pst!=null){
					pst.close();
				}
				if(con!=null){
					con.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		
		
	}
	
}
